import os,sys,time
import vehicle_model
import asyncio
import queue
import _thread

# msgQ = queue.Queue()

# def msg_dispatch_proc():
#     global msgQ
#     print("MSG handler ...")

#     while 1:
#         if msgQ.qsize()>0:
#             msg = msgQ.get()
#             if msg == "doorOpen":
#                 vehicle_model.doorOpen()
#             elif msg == "doorClose":
#                 vehicle_model.doorClose()
#         else:
#             time.sleep(0.2)

# _thread.start_new_thread(msg_dispatch_proc,(()))

class SPEED():
    def __init__(self):
        pass
    def subscribe(self, vss_path):
        print("User sub vss path.")

Speed=SPEED()


#Cabin.Door.Row1.Left.IsOpen
#Cabin.Door.Row1.Left.IsLocked

#Cabin.Seat.Row1.Pos1.Position
#Cabin.Seat.Row1.Pos1.Height
#Cabin.Seat.Row1.Pos1.Backrest.Recline

#Cabin.Lights.AmbientLight
#Cabin.Lights.IsDomeOn

#Body.Lights.Running.IsOn
#Body.Lights.Brake.IsActive

#Body.Windshield.Front.Wiping.Mode  (INTERVAL)


class POSITION():
    def __init__(self):
        self.pos = 0
        pass
    async def set(self, val):
        print("CURRENT POS:", self.pos)
        if val>self.pos:
            vehicle_model.seatPositionForward()
        if val<self.pos:
            vehicle_model.seatPositionBackward()
        print("SET VSS VALUE TO:", val)
        self.pos = val
    async def get(self):
        print("GET VSS vALUE.")
        return self.pos

class HEIGHT():
    def __init__(self):
        self.height = 0
        pass
    async def set(self, val):
        if val>self.height:
            vehicle_model.seatHeightPlus()
        if val<self.height:
            vehicle_model.seatHeightMinus()
        print("SET VSS VALUE TO:", val)
        self.height = val
    async def get(self):
        print("GET VSS vALUE.")
        return self.height

class RECLINE():
    def __init__(self):
        self.recline = 0
        pass
    async def set(self, val):
        if val>self.recline:
            vehicle_model.backrestReclinePlus()
        if val<self.recline:
            vehicle_model.backrestReclineMinus()
        print("SET VSS VALUE TO:", val)
        self.recline = val
    async def get(self):
        print("GET VSS vALUE.")
        return self.recline

class BACKREST():
    def __init__(self):
        self.Recline = RECLINE()
        pass

class POS1():
    def __init__(self):
        self.Position = POSITION()
        self.Height = HEIGHT()
        self.Backrest = BACKREST()
        pass

class ISOPEN():
    def __init__(self):
        pass
    async def set(self, val):
        #global msgQ
        if val:
            vehicle_model.doorOpen()
            #msgQ.put("doorOpen")

        print("SET VSS VALUE TO:", val)
    async def get(self):
        print("GET VSS vALUE.")

class ISLOCKED():
    def __init__(self):
        pass
    async def set(self, val):
        if val:
           vehicle_model.doorClose()
        print("SET VSS VALUE TO:", val)
    async def get(self):
        print("GET VSS vALUE.")


class LEFT():
    def __init__(self):
        self.IsOpen = ISOPEN()
        self.IsLocked = ISLOCKED()
        pass

class ROW1():
    def __init__(self):
        self.Pos1 = POS1()
        self.Left = LEFT()
        pass

class SEAT():
    def __init__(self):
        self.Row1 = ROW1()
        pass

class DOOR():
    def __init__(self):
        self.Row1 = ROW1()
        pass

class AMBIENTLIGHT():
    def __init__(self):
        pass
    async def set(self, val):
        if val:
            vehicle_model.setAmbientLight(val)
        print("SET VSS VALUE TO:", val)
    async def get(self):
        print("GET VSS vALUE.")

class ISDOMEON():
    def __init__(self):
        pass
    async def set(self, val):
        vehicle_model.controlReadingLight(val)    
        print("SET VSS VALUE TO:", val)
    async def get(self):
        print("GET VSS vALUE.")

class ISON():
    def __init__(self):
        pass
    async def set(self, val):
        vehicle_model.controlFrontLight(val)    
        print("SET VSS VALUE TO:", val)
    async def get(self):
        print("GET VSS vALUE.")

class RUNNING():
    def __init__(self):
        self.IsOn = ISON()
        pass

class ISACTIVE():
    def __init__(self):
        pass
    async def set(self, val):
        vehicle_model.controlBrakeLight(val)    
        print("SET VSS VALUE TO:", val)
    async def get(self):
        print("GET VSS vALUE.")

class BRAKE():
    def __init__(self):
        self.IsActive = ISACTIVE()
        pass

class LIGHTS():
    def __init__(self):
        self.AmbientLight = AMBIENTLIGHT()
        self.IsDomeOn = ISDOMEON()
        self.Running = RUNNING()
        self.Brake = BRAKE()
        pass

class CABIN():
    def __init__(self):
        self.Seat = SEAT()
        self.Door = DOOR()
        self.Lights = LIGHTS()
        pass

class MODE():
    def __init__(self):
        pass
    async def set(self, val):
        vehicle_model.controlWiper(val)    
        print("SET VSS VALUE TO:", val)
    async def get(self):
        print("GET VSS vALUE.")

class WIPING():
    def __init__(self):
        self.Mode = MODE()
        pass

class FRONT():
    def __init__(self):
        self.Wiping = WIPING()
        pass

class WINDSHIELD():
    def __init__(self):
        self.Front = FRONT()
        pass

class BODY():
    def __init__(self):
        self.Windshield = WINDSHIELD()
        self.Lights = LIGHTS()
        pass

Cabin = CABIN()
Body = BODY()



